package cn.itcast.tools.java发送文件.客户端服务器;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class server {
    public static void main(String[] args) throws Exception
    {
        ServerSocket ss = new ServerSocket(10005);//建立服务
        Socket s = ss.accept();//接收数据
        BufferedReader bufin = new BufferedReader(new InputStreamReader(s.getInputStream()));//读取接收到的数据
        PrintWriter out = new PrintWriter(new FileWriter("io2.txt"),true);//写入到IO.TXT文本
        String line = null;
        while((line = bufin.readLine())!= null)//读一行写入一行
        {
//     if("over".equals(line))
//       break;
            out.println(line);
        }
        PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
        pw.println("上传成功！");
        out.close();
        ss.close();
        s.close();
    }
}
